% Sheperd plot from our timing data
% Takes a 1D array of times generated by analyzeTiming(...);
% Generates a plot like Sheperd and Metzler.
function av = plotShepard(times)

N=round(sqrt(length(times)));
a=reshape(times,N,N)';
miss_value = 2000; %2000 for delay set-up, 3000 for non-delay set-up

% jason- changes to work with N=64 (false positives) and N=16 (no test of
% mirror vs regular J);  THIS LOGIC MIGHT FAIL WITH OTHER SETUPS
a=[a(1:4,1:4);a(5:8,end-3:end)];%pulls out miss values for N=64

for i = 2:N
    a(i,:)=circshift(a(i,:),[0 -(i-1)]);
end
a(:,2:end)=fliplr(a(:,2:end));

for c=1:4,
    av(c)=mean( a( find( a(:,c)~=miss_value ), c ) );
    st(c)=std( a( find( a(:,c)~=miss_value ), c ) );
    ct(c)=length( a( find( a(:,c)~=miss_value ), c ) );
end
ct

errorbar([0 90 180 270],av,st)
xlabel('Angular difference (degrees)','FontSize',12)
ylabel('Response time (ms)','FontSize',12)